package pl.umk.mat.fred.unicore.urc.storagemanagement.tree.nodes;

import java.util.ArrayList;
import java.util.List;

public abstract class Node {
	
	protected String path;
	protected Node parent;
	private List<Node> children;
	private RootNode rootNode;
	private String lastCriteria = "";
	private boolean lastSelected = true;
	
	public void add(Node node) {
		getChildren().add(node);
	}
	
	public List<Node> getChildren() {
		if (children == null) {
			children = new ArrayList<Node>();
		}
		return children;
	}
	
	public Node getParent() {
		/*
		if ((!getRootNode().areStoragesVisible()) &&
			(parent instanceof StorageNode)) {
			System.out.println("Return " + parent.getParent().getClass());
			return parent.getParent();
		}
		*/
		//System.out.println("Return2 " + parent.getClass());
		return parent;
	}
	
	public void setChildren(List<Node> children) {
		this.children = children;
	}
	
	public void setParent(Node parent) {
		this.parent = parent;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}
	
	public RootNode getRootNode(){
		if (rootNode != null) {
			return rootNode;
		}
		rootNode = getParent().getRootNode();
		return rootNode;
	}
	
	public Node clone(Node nodeParent) {
		return null;
	}

	public String getLastCriteria() {
  	return lastCriteria;
  }

	public void setLastCriteria(String lastCriteria) {
  	this.lastCriteria = lastCriteria;
  }

	public boolean getLastSelected() {
  	return lastSelected;
  }

	public void setLastSelected(boolean lastSelected) {
  	this.lastSelected = lastSelected;
  }
		
}
